/**
 * Created with JetBrains PhpStorm.
 * User: zhenzhen
 * Date: 12-9-14
 * Time: 上午10:08
 * To change this template use File | Settings | File Templates.
 */
$(function(){
    var cookie_pindex=getCookie('pindex');//className==.by的cookie值
    //cookie_pindex=cookie_pindex=='undefined'?'':cookie_pindex;
    var cookie_aindex=getCookie('aindex')
    var cookie_main_a=getCookie('main_a')

    $('.by a').eq(cookie_aindex).addClass('active1');
    $('.solidblockmenu a').removeClass('current')
    $('.solidblockmenu a').eq(cookie_main_a).addClass('current');
    $('.by').eq(cookie_pindex).show();

    $('.byp').click(function(){
        var pindex=$('.byp').index($(this));
        $('.by').eq(pindex).toggle();
        //removeCookie('pindex')
        setCookie('pindex',pindex,10);
    })
    $('.by a').click(function(){
        var aindex=$('.by a').index($(this));
        //removeCookie('aindex');
        setCookie('aindex',aindex,10);
    })

    $('.solidblockmenu a').click(function(){
        var main_a=$('.solidblockmenu a').index($(this))
        //removeCookie('main_a');
        removeCookie('aindex')
        removeCookie('pindex')
        setCookie('main_a',main_a,10)
    })
})

function setCookie(name,value,iDate){
    var oDate=new Date()
    oDate.setDate(oDate.getDate()+iDate);
    document.cookie=name+'='+value+';expires='+oDate;

}
function getCookie(name){
    var arr=document.cookie.split("; ");
    for(var i=0;i<arr.length;i++){
        var arr2=arr[i].split("=")

        if(arr2[0]==name){
            return arr2[1];
        }
    }

}
function removeCookie(name){
    setCookie(name,"1",-1);
}